package kr.co.mcshop.qnareply;

import java.util.Locale;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@RequestMapping(value = "/QnA")
@Controller
public class QnAReplyController {
	private static final Logger logger = LoggerFactory
			.getLogger(QnAReplyController.class);

	@Autowired
	private QnAReplyService qnareplyService;

	@RequestMapping(value = "/replyInsert", method = RequestMethod.POST)
	public String replyInsert(Model model, @RequestParam Map map) {
		System.out.println(map);
		qnareplyService.replyInsert(map);
		return "redirect:/QnA/QnA_detail?board_no="+map.get("board_no");
	}

	@RequestMapping(value = "/qnareplyUpdate", method = RequestMethod.POST)
	public String qnareplyupdate(Locale locale, Model model, @RequestParam Map map) {
		System.out.println(map);
		qnareplyService.updateqnareply(map);
		return "redirect:/QnA/QnA_detail?board_no="+map.get("board_no");
	}
	
	@RequestMapping(value = "/qnareplyDelete", method = RequestMethod.GET)
	public String qnareplyDelete(Locale locale, Model model, @RequestParam Map map) {
		System.out.println(map);
		qnareplyService.qnareplyDelete(map);
		return "redirect:QnA_detail";
	}
	@RequestMapping(value = "text")
	public String text() {
		return "text";
	}
}
